package com.finger.gulimall.search.controller;

import com.finger.common.to.es.SkuEsModel;
import com.finger.common.utils.R;
import com.finger.gulimall.search.service.ProductSaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;


@RequestMapping("/search/save")
@RestController
public class ElasticSaveController {

    @Autowired
    private ProductSaveService productSaveService;

    @PostMapping("/skuProductSave")
    public R skuProductSave(@RequestBody List<SkuEsModel> skuEsModels) {

        try {
            boolean isSaveSuccess = productSaveService.productStatusUp(skuEsModels);
        } catch (IOException e) {
            e.printStackTrace();
            return R.error().put("message", e.getMessage());
        }

        return R.ok();
    }

}
